package com.github.base.controller;

import com.github.base.annotation.SysLog;
import com.github.base.dto.log.LogDTO;
import com.github.base.service.LogService;
import com.github.base.utils.Result;
import com.github.base.vo.log.LogListVO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@Tag(name = "日志模块")
@RequestMapping("/log")
@AllArgsConstructor
public class LogController {
    private final LogService logService;

    @Operation(summary = "账号-分页查询")
    @ApiOperationSupport(order = 1)
    @PostMapping(value = "/pageList")
    public Result<Page<LogListVO>> pageList(@Validated @RequestBody LogDTO logDTO) {
        Page<LogListVO> allList = logService.pageList(logDTO);
        return Result.ok(allList);
    }

    @PostMapping(value = "/delete/{id}")
    @Operation(summary = "删除日志信息")
    @ApiOperationSupport(order = 2)
    @SysLog(module = "日志模块", value = "删除日志信息")
    public Result<?> delete(@PathVariable(value = "id") Integer id) {
        logService.delete(id);
        return Result.ok();
    }
}
